{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerheader.html"}
{literal}
<script type="text/javascript">

    $(function(){
        var Obmobile = $(".mobile");
        var Obcode = $("input[name=code]");
        var Obpasswd = $("input[name=password]");
        var Obrepasswd = $("input[name=repassword]");
        //下一步
        $('.lcl_btn').click(function(){
            if(codeEmpty(Obcode) === false){
                return false;
            }else{
                var mobile = Obmobile.text();

                var passwd = Obpasswd.val();
                var repasswd = Obrepasswd.val();
                var codetime = Obmobile.attr("v");
                $.ajax({
                    url:'/register/savereg',
                    data:{mobile:mobile,passwd:passwd,repasswd:repasswd,codetime:codetime},
                    type:'POST',
                    success:function(data){
                        var data = eval("("+data+")");
                        var code = data.code;
                        var msg = data.msg;
                        var data = data.data;
                        if(code == 99){
                            $('.msg').html(msg);
                            $('.msg').attr("v","false");
                            return;
                        }
                        if(code ==37){
                            $('.errormsg').html(msg);
                            $('.errormsg').attr("v","false");
                            return;
                        }
                        if(code ==34){
                            $('.repasswordmsg').html(msg);
                            $('.repasswordmsg').attr("v","false");
                            return;
                        }
                        if(code ==36){
                            $('.passwordmsg').html(msg);
                            $('.passwordmsg').attr("v","false");
                            return;
                        }
                        else{
                            window.location.href="/register/success";
                            return true;
                        }
                    },
                    dataType:'text'
                });

            }
        });


        var count = 60;
        var myCountDown;
        $(function(){
            $(".lcl_hq").click(function(){
                myCountDown = setInterval(countDown,1000);

                var mobile = Obmobile.text();
                var codetime = Obmobile.attr("v");
                $.ajax({
                    url:'/register/sendcode',
                    data:{mobile:mobile,codetime:codetime},
                    type:'POST',
                    success:function(data){

                        if(data == "-6"){
                            $(".msg").html("不允许重复发送");
                            return;
                        }
                        if(data == "-5"){
                            $(".msg").html("手机号码不正确");
                            return;
                        }
                        return true;
                    },
                    dataType:'text'
                });
            });
        });

        function countDown(){
            $(".lcl_hq").attr("disabled",true);
            $(".lcl_hq").css("background","#999999");
            $(".lcl_hq").val("重新获取验证码 （"+ count +"）");
            count--;
            if(count==0){
                $(".lcl_hq").val("获取验证码").removeAttr("disabled");
                $(".lcl_hq").css("background","#f4f4f4");
                clearInterval(myCountDown);
                count = 60;
            }
        }



        Obcode.blur(function(){
            codeEmpty(Obcode);
        });

    });


    function codeEmpty(obj){
        var code = obj.val();
        var mobile = $(".mobile").text();
        if(code==''){
            $('.msg').html("请输入验证码！");
            $('.msg').attr("v","false");
            return false;
        }else{
            $.ajax({
                url:'/register/confirmPhonecode',
                data:{code:code,mobile:mobile},
                type:'POST',
                success:function(data){
                    var data = eval("("+data+")");
                    var code = data.code;
                    var msg = data.msg;
                    var data = data.data;
                    if(code == 99){
                        $('.msg').html(msg);
                        $('.msg').attr("v","false");
                        return;
                    }else{
                        $('.msg').html("");
                        $('.msg').attr("v","true");
                        return true;
                    }
                },
                dataType:'text'
            });
            var stauts =$('.msg').attr("v");
            if(stauts == 'false'){
                return false;
            }else{
                return true;
            }
        }
    }
</script>
{/literal}
<div class="clearfix"></div>
<iframe name="hidden_form" src="javascript:void(0);" style="display:none;"></iframe>
<div class="login_wrap">
	<div class="register_wrap">
        <ul class="technological_process">
            <li class="curr"><i>1</i>注册账户</li>
            <li class="curr"><i>2</i>填写手机验证码</li>
            <li><i>3</i>注册成功</li>
        </ul>
        <ul class="tp_cp">

            <li hidden><b>注册号码：</b><span class="mobile" v="{$codetime}">{$mobile}</span>
            <span class="phonemsg"></span></li>
            <li><span  class="errormsg orange"style="color: red" v="false"></span></li></li>
            <li><span class="fl mt8">　验证码：</span><input name="code" class="code lcl_text wid18 fl" type="text"  placeholder="请输入验证码"/>
                <div class="code-pic"><input class="lcl_hq" id="lcl_hq" type="button" value="获取验证码"/></div>
                <span class="msg orange" v="false"></span></li>
            <li><span>　　密码：</span><input class="lcl_text" type="password" name="password"/>
                <span class="passwordmsg orange"></span>
            </li>
            <li><span>确认密码：</span><input class="lcl_text" type="password" name="repassword"/>
                <span class="repasswordmsg orange"></span></li>
            <li class="tp_cp_server"><input class="lcl_btn" type="button" value="立即注册"/></li>
        </ul>
    </div>
</div>


{include file = $smarty.const.APPLICATION_PATH|cat:"/application/views/registerfooter.html"}
